;;;Place title text, underline and scale text.
;;;       Uses DIMSCALE and LUNITS to format scale string and scale bubble
;;;       and text.
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;              
;;;		All rights reserved without prejudice.
;;;
;;;	Copyright:	9-30-93
;;;	Edited:		6-17-2003
;;;
;;;       Requirements:   GETSTYLE.LSP (gets current style values and changes
;;;                                     them as req'd for this function only.)
;;;
(DEFUN C:PLTL ( / attdlg pt1 mpb mpe clayr dimsc txht ttlsz sclsz
                dscl ip0 ip1 ip2 llen layt2 layt6)
  (setvar "cmdecho" 0)
  (if dimscl nil (load"dimscl"))
  (dimscl)
  (setq old_prod prod)
  (gvpno)
  (setq attdlg (getvar"attdia")
        attrq (getvar"attreq")
        clayr (getvar"clayer")
        ntz 0                                   ;(* 1001 dimsc)
        txht (getvar"textsize")
        pt1 (getpoint "\nTitle center point ")
        pt1 (list(car pt1)(cadr pt1)ntz)
        mpb pt1 ;(polar pt1 (+(- 0(getvar"viewtwist"))pi) (* dimsc 0.375))
        plttl (strcase (ustr 1 "\nEnter title text" (if plttl plttl "PLAN") T))
        ttlsz (* dimsc 0.1 1.75)                        ;Title height (175 template)
        llen (* (strlen plttl) ttlsz)                   ;(+(/ (strlen plttl) 12.0)2.0)
        sclsz (* dimsc 0.1 1.25)                        ;dimscale * 87.5 template
        sctyp (ukword 1 "Not To" "\nN.T.S. or To scale? (Not or To) " "T")
;;;        prod "PLAN"
        colr "1"
        modf "TEXT"
        e1ang (- 0 (getvar"viewtwist"))
  );setq
  (setvar "attreq" 0)
  (if getstyle (getstyle "A")(progn (load "getstyle")(getstyle "A")))
  (c:mklayr)
  (if (or(=(substr clayr 2 9)"PLAN7TEXT") mjrg)
    (progn
      (if (= (substr sctyp 1 1) "T")
        (if (or (= (getvar"lunits")4)(= (getvar"lunits")3))
          (setq dscl (strcat (rtos(/ 1.0(/ dimsc 12.0))4 6) " = 1'-0\""))
          (setq dscl (strcat "1\" = "(rtos dimsc 2 0)"'"))
        );if
        (setq dscl "NOT TO SCALE")
      );if
      (setq ip0 mpb ;(polar mpb (+(- 0(getvar"viewtwist"))pi)(* dimsc 1.75))   ;(polar mpb e1ang (* dimsc 0.2))
            ip1 (polar ip0 (+ e1ang(* 1.50 pi)) (* sclsz 1.125))    ;was (* sclsz 1.75)
            ip2 (polar ip0 (+ e1ang(* 0.50 pi)) (* ttlsz 1.125))    ;was (* ttlsz 0.625)
            sclln (*(strlen dscl) sclsz)
      );setq
;;;      (setvar "attdia" 0)
      (setvar "cecolor" "bylayer")
  (setq colr "6"
	modf "TEXT")
  (c:mklayr)
  (entmake
    (list
      (cons 0 "TEXT")
      (cons 10 ip1)
      (cons 11 ip1)
      (cons 40 sclsz)
      (cons 50 (- 0(getvar"viewtwist")))
      (cons 72 4)
      (cons 73 2)
      (cons 1 dscl)
    )
  );entmake
  (setq txten1 (entget(entlast))
        txtbx1 (textbox txten1)
        txtln1 (abs(-(car(nth 1 txtbx1))(car(nth 0 txtbx1))))
        colr "2")
  (c:mklayr)
  (entmake
    (list
      (cons 0 "TEXT")
      (cons 10 ip2)
      (cons 11 ip2)
      (cons 40 ttlsz)
      (cons 50 (- 0(getvar"viewtwist")))
      (cons 72 4)
      (cons 73 2)
      (cons 1 plttl)
    )
  );entmake
  (setq ttltxbx (textbox(entget(entlast))))
  (setq txten2 (entget(entlast))
        txtbx2 (textbox txten2)
        txtln2 (abs(-(car(nth 1 txtbx2))(car(nth 0 txtbx2))))
        txtln (* dimsc 1.75)           ;(+ ttlsz(max txtln1 txtln2))
        lp1 (polar mpb (+(- 0(getvar"viewtwist"))pi) (/(distance(car ttltxbx)(cadr ttltxbx))2.0))
        lp2 (polar lp1 (- 0(getvar"viewtwist"))(distance(car ttltxbx)(cadr ttltxbx)))
        ;mpe (polar mpb (+(- 0(getvar"viewtwist"))pi) txtln)
  );setq
;;;  (SETQ modf "SYMB")
;;;  (c:mklayr)
  (entmake
    (list
      (cons 0 "LINE")
      (cons 10 lp1)
      (cons 11 lp2)
    )
  );entmake
;;;  (setq colr "2")
;;;  (c:mklayr)
;;;       (command ".insert" "b" pt1 dimsc dimsc e1ang)
;;;       (command ".ddatte" "l")
;;;       (setvar "clayer" clayr)
;;;       (setvar "attdia" attdlg)
;;;       (setvar "attreq" attrq)
;;;       (setvar "textsize" txht)
;;;       (getstyle "")
;;;       (setvar "cmdecho" 1)
;;;       (command)
     );progn
   );if
  (setq prod old_prod)
   (princ)
);DEFUN C:DTTL
